<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>学生的签到查看</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="./layui/css/layui.css">
	<script type="text/javascript" src="./layui/layui.js" charset="UTF-8"></script>
	<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
	<div class="layui-inline">
      	<label class="layui-form-label">签到ID(在老师处获取)</label>
      	<div class="layui-input-block">
       		<input type="text" name="coursename" id="demoReload" autocomplete="off" class="layui-input">
      	</div>
    </div>
    <div class="layui-inline">
      	<button class="layui-btn" data-type="reload" id="searchBtn">查询</button>
   	</div>
  	<table class="layui-hide" id="test" lay-filter="test"></table>    

	<script type="text/html" id="barDemo">
		<a class="layui-btn layui-btn-normal layui-btn-sm" lay-event="check">进入签到</a>
	</script>
	
	<script>
		layui.use(['table','layer'], function(){
			
		  	var $ = layui.jquery
		  	,table = layui.table
		  	,layer = layui.layer;
		  	
		  	
		  	
		  	//搜索，加载表格
			$('#searchBtn').on('click',function(){
		  		var demoReload = $("#demoReload").val();
		  		
		  	//动态表格，获取数据库数据
		  	var tableIns = table.render({
				elem: '#test'
				,id: 'test'
				,url: 'GetCheckById.do'
				,where: {
		  				'checkid':demoReload
		  			}
				,toolbar:  '#toolbarDemo'
				,defaultToolbar: ['filter', 'exports', 'print']
				,title: '签到入口'
				,page:true
				,limit:4
				,limits:[2,3,4,5,6]
				,cols: [[
					{type:'numbers',width:80}
			  		,{field:'checkid', title:'签到ID'}
			  		,{field:'courseid', title:'课程ID'}
			  		,{field:'checktime', title:'发起时间'}
			        ,{fixed: 'right', width: 150, align:'center', toolbar: '#barDemo'}
					]],
				parseData:function(res) {
					var result;
	                if (this.page.curr)
	                	result = res.data.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
	                else
	                    result = res.data.slice(0, this.limit);
	               	return {
	               		"code": res.code, //解析接口状态
	               		"msg": res.msg, //解析提示文本
	               		"data": res.data
	               		};
	               	}
			});
		  	});
			
		  	
		  	table.on('toolbar(test)', function(obj){
		   	 	var checkStatus = table.checkStatus(obj.config.id);
		    	switch(obj.event){
		    	case 'insertCourse':
		        	layer.open({
		            	type: 2 
		            	,title: '添加课程'
		            	,area: ['400px', '400px']
		            	,content:['insertCourse1.do']
		            	,maxmin: true
		            	,btn: ['关闭']
		        		,yes: function(){
		    				layer.closeAll();
		        		}
		        		,end:function(){
		        			location.reload();
		        		}
		          	});     
		        	break;
		    	}
			});
			//进行签到
			table.on('tool(test)', function(obj){
				var data = obj.data;
				if(obj.event === 'check'){
					layer.open({
		            	type: 2 
		            	,title: '进行签到'
		            	,area: ['800px', '600px']
		            	,content:['face.html']
		            	,data:{
		            		checkid:data.checkid}
		            	,maxmin: true
		            	,btn: ['关闭']
		        		,yes: function(){
		    				layer.closeAll();
		        		}
		        		,end:function(){
		        			location.reload();
		        		}
		          	}); 					
				} 
			});
	})
	</script>

</body>
</html>